import { LoginDao } from './../dao/loginDao'
import { Loggor } from './../loggor'
var constants = {
  SUCCESS: 'success',
  FAILED: 'failed',
  TRUE_BOOLEAN: true,
  FALSE_BOOLEAN: false
}
export class LoginService {
  private readonly loginDao = new LoginDao()
  checkEmail(params: any): Promise<boolean> {
    return this.loginDao.checkEmail(params)
  }
  register(params: any): Promise<boolean> {
    if (params.account && params.name && params.email && params.password) {
      params.creator = params.account
      params.updater = params.account
      return this.loginDao.register(params)
    } else {
      Loggor.error('data check failed')
      return new Promise((resolve, reject) => {
        resolve(false)
      })
    }
  }
  login(params: any): Promise<string> {
    return this.loginDao.login(params)
  }
  verifyLogin(params: any): Promise<string> {
    return this.loginDao.verifyLogin(params)
  }
}